<template>
  <div class="global-message">
    <div class="container">
      <div class="icon">
        <img :src="messageIcon[message]" alt=""/>
      </div>
      <div class="title">
        <span>{{ messageDes[message] }}</span>
      </div>
      <div class="btn">
        <el-button type="primary" size="medium" @click="receive">
          知道了
        </el-button>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    props: {
      message: {
        type: String,
        default: "error"
      }
    },
    data() {
      return {
        messageIcon: {
          success: require("../../assets/img/popconfirmSuccess.png"),
          error: require("../../assets/img/popconfirmLose.png")
        },
        messageDes: {
          success: "操作成功",
          error: "操作失败"
        }
      }
    },
    methods: {
      receive() {
        this.$emit("receive", true)
      }
    }
  }
</script>

<style lang="scss" scoped>
  .global-message {
    position: absolute;
    width: 338px;
    height: 210px;
    left: 40%;
    top: 300px;
    background: #ffffff;
    box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.25);
    border-radius: 5px;
    display: flex;
    justify-content: center;
    z-index: 4;

    .container {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: space-around;

      .icon {
        margin-top: 25px;

        img {
          width: 54px;
          height: 54px;
        }
      }

      .btn {
        margin-bottom: 8px;
      }
    }
  }
</style>
